package com.rec.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.rec.entity.Sections;
import com.rec.entity.Students;
import com.rec.service.SectionsService;

@RestController
@RequestMapping("sections")
@CrossOrigin
public class SectionsController {
	/**
	 * 获取所有
	 */
	@Autowired
	private SectionsService s;
	
	
	@RequestMapping("getAll")
	public Map<String,Object> getBySearch(String name,String remark,Integer page, Integer limit) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("name", name);
		params.put("remark", remark);
		limit = limit == null ? 10 : limit;
		page = page == null ? 0 : page - 1;
		params.put("limit", limit);
		params.put("page", page);
		System.out.println(s.all(params));
		return s.all(params);
	}
	/**
	 *String name   姓名
	 *String remark 备注
	 * @return
	 */
	@RequestMapping("add")
	public Integer add(Sections sec){
		return s.add(sec);
	}
	/**
	 * @param id
	 * @param name
	 * @param remark
	 */
	@RequestMapping("update")
	public Integer update(Sections sec){
		
		return s.update(sec);
	}
	
	/**
	 * 单删
	 * @param idx
	 * @return
	 */
	@RequestMapping("delete")
	public Integer delete(Integer id){
		
		return s.delete(id);
	}
	
	
	
	
	
	
	
	
	
	
}
